package org.mat.ipaas.ucenter.bff.admin.modules.open;

import com.alibaba.fastjson.JSONObject;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.api.open.SystemApiRestAPI;
import org.mat.ipaas.ucenter.service.dto.open.DataLogDTO;
import org.mat.ipaas.ucenter.service.dto.open.OnlineAuthDTO;
import org.mat.ipaas.ucenter.service.dto.open.message.*;
import org.mat.ipaas.ucenter.service.dto.system.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * 服务化 system模块 对外接口请求类
 *
 */
@RestController
@RequestMapping("/sys/api")
class SystemApiController {

    @Autowired
    private SystemApiRestAPI systemApiRestAPI;

    /**
     * 发送系统消息
     *
     * @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息
     */
    @PostMapping("/sendSysAnnouncement")
    public void sendSysAnnouncement(@RequestBody MessageDTO message) {
        systemApiRestAPI.sendSysAnnouncement(message);
    }

    /**
     * 发送消息 附带业务参数
     *
     * @param message 使用构造器赋值参数
     */
    @PostMapping("/sendBusAnnouncement")
    public void sendBusAnnouncement(@RequestBody BusMessageDTO message) {
        systemApiRestAPI.sendBusAnnouncement(message);
    }

    /**
     * 通过模板发送消息
     *
     * @param message 使用构造器赋值参数
     */
    @PostMapping("/sendTemplateAnnouncement")
    public void sendTemplateAnnouncement(@RequestBody TemplateMessageDTO message) {
        systemApiRestAPI.sendTemplateAnnouncement(message);
    }

    /**
     * 通过模板发送消息 附带业务参数
     *
     * @param message 使用构造器赋值参数
     */
    @PostMapping("/sendBusTemplateAnnouncement")
    public void sendBusTemplateAnnouncement(@RequestBody BusTemplateMessageDTO message) {
        systemApiRestAPI.sendBusTemplateAnnouncement(message);
    }

    /**
     * 通过消息中心模板，生成推送内容
     *
     * @param templateDTO 使用构造器赋值参数
     * @return
     */
    @PostMapping("/parseTemplateByCode")
    public String parseTemplateByCode(@RequestBody TemplateDTO templateDTO) {
        String ret = systemApiRestAPI.parseTemplateByCode(templateDTO);
        return ret;
    }

    /**
     * 根据业务类型busType及业务busId修改消息已读
     */
    @GetMapping("/updateSysAnnounReadFlag")
    public void updateSysAnnounReadFlag(@RequestParam("busType") String busType, @RequestParam("busId") String busId) {
        systemApiRestAPI.updateSysAnnounReadFlag(busType, busId);
    }

    /**
     * 根据用户账号查询用户信息
     *
     * @param username
     * @return
     */
    @GetMapping("/getUserByName")
    public LoginUserDTO getUserByName(@RequestParam("username") String username) {
        LoginUserDTO loginUserDTO = systemApiRestAPI.getUserByName(username);
        return loginUserDTO;
    }

    /**
     * 根据用户id查询用户信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getUserById")
    public LoginUserDTO getUserById(@RequestParam("id") String id) {
        LoginUserDTO loginUserDTO = systemApiRestAPI.getUserById(id);
        return loginUserDTO;
    }

    /**
     * 通过用户账号查询角色集合
     *
     * @param username
     * @return
     */
    @GetMapping("/getRolesByUsername")
    public List<String> getRolesByUsername(@RequestParam("username") String username) {
        List<String> rolesByUsername = systemApiRestAPI.getRolesByUsername(username);
        return rolesByUsername;
    }

    /**
     * 通过用户账号查询部门集合
     *
     * @param username
     * @return 部门 id
     */
    @GetMapping("/getDepartIdsByUsername")
    public List<String> getDepartIdsByUsername(@RequestParam("username") String username) {
        List<String> departIdsByUsername = systemApiRestAPI.getDepartIdsByUsername(username);
        return departIdsByUsername;
    }

    /**
     * 通过用户账号查询部门 name
     *
     * @param username
     * @return 部门 name
     */
    @GetMapping("/getDepartNamesByUsername")
    public List<String> getDepartNamesByUsername(@RequestParam("username") String username) {
        List<String> departNamesByUsername = systemApiRestAPI.getDepartNamesByUsername(username);
        return departNamesByUsername;
    }


    /**
     * 获取数据字典
     *
     * @param code
     * @return
     */
    @GetMapping("/queryDictItemsByCode")
    public List<DictModelDTO> queryDictItemsByCode(@RequestParam("code") String code) {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.queryDictItemsByCode(code);
        return dictModelDTOList;
    }

    /**
     * 获取有效的数据字典
     *
     * @param code
     * @return
     */
    @GetMapping("/queryEnableDictItemsByCode")
    public List<DictModelDTO> queryEnableDictItemsByCode(@RequestParam("code") String code) {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.queryEnableDictItemsByCode(code);
        return dictModelDTOList;
    }


    /**
     * 查询所有的父级字典，按照create_time排序
     */
    @GetMapping("/queryAllDict")
    public List<DictModelDTO> queryAllDict() {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.queryAllDict();
        return dictModelDTOList;
    }

    /**
     * 查询所有分类字典
     *
     * @return
     */
    @GetMapping("/queryAllSysCategory")
    public List<SysCategoryModelDTO> queryAllSysCategory() {
        List<SysCategoryModelDTO> sysCategoryModels = systemApiRestAPI.queryAllSysCategory();
        return sysCategoryModels;
    }


    /**
     * 查询所有部门 作为字典信息 id -->value,departName -->text
     *
     * @return
     */
    @GetMapping("/queryAllDepartBackDictModel")
    public List<DictModelDTO> queryAllDepartBackDictModel() {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.queryAllDepartBackDictModel();
        return dictModelDTOList;
    }

    /**
     * 获取所有角色 带参
     * roleIds 默认选中角色
     *
     * @return
     */
    @GetMapping("/queryAllRole")
    public List<ComboModelDTO> queryAllRole(@RequestParam(name = "roleIds", required = false) String[] roleIds) {
        List<ComboModelDTO> comboModels = systemApiRestAPI.queryAllRole(roleIds);
        return comboModels;
    }

    /**
     * 通过用户账号查询角色Id集合
     *
     * @param username
     * @return
     */
    @GetMapping("/getRoleIdsByUsername")
    public List<String> getRoleIdsByUsername(@RequestParam("username") String username) {
        List<String> roleIdsByUsername = systemApiRestAPI.getRoleIdsByUsername(username);
        return roleIdsByUsername;
    }

    /**
     * 通过部门编号查询部门id
     *
     * @param orgCode
     * @return
     */
    @GetMapping("/getDepartIdsByOrgCode")
    public String getDepartIdsByOrgCode(@RequestParam("orgCode") String orgCode) {
        String departIdsByOrgCode = systemApiRestAPI.getDepartIdsByOrgCode(orgCode);
        return departIdsByOrgCode;
    }

    /**
     * 查询所有部门
     *
     * @return
     */
    @GetMapping("/getAllSysDepart")
    public List<SysDepartModelDTO> getAllSysDepart() {
        List<SysDepartModelDTO> allSysDepart = systemApiRestAPI.getAllSysDepart();
        return allSysDepart;
    }

    /**
     * 根据 id 查询数据库中存储的 DynamicDataSourceModel
     *
     * @param dbSourceId
     * @return
     */
    @GetMapping("/getDynamicDbSourceById")
    public DynamicDataSourceModelDTO getDynamicDbSourceById(@RequestParam("dbSourceId") String dbSourceId) {
        DynamicDataSourceModelDTO dynamicDbSourceById = systemApiRestAPI.getDynamicDbSourceById(dbSourceId);
        return dynamicDbSourceById;
    }


    /**
     * 根据部门Id获取部门负责人
     *
     * @param deptId
     * @return
     */
    @GetMapping("/getDeptHeadByDepId")
    public List<String> getDeptHeadByDepId(@RequestParam("deptId") String deptId) {
        List<String> deptHeadByDepId = systemApiRestAPI.getDeptHeadByDepId(deptId);
        return deptHeadByDepId;
    }

    /**
     * 查找父级部门
     *
     * @param departId
     * @return
     */
    @GetMapping("/getParentDepartId")
    public DictModelDTO getParentDepartId(@RequestParam("departId") String departId) {
        DictModelDTO parentDepartId = systemApiRestAPI.getParentDepartId(departId);
        return parentDepartId;
    }

    /**
     * 根据 code 查询数据库中存储的 DynamicDataSourceModel
     *
     * @param dbSourceCode
     * @return
     */
    @GetMapping("/getDynamicDbSourceByCode")
    public DynamicDataSourceModelDTO getDynamicDbSourceByCode(@RequestParam("dbSourceCode") String dbSourceCode) {
        DynamicDataSourceModelDTO dynamicDbSourceByCode = systemApiRestAPI.getDynamicDbSourceByCode(dbSourceCode);
        return dynamicDbSourceByCode;
    }

    /**
     * 给指定用户发消息
     *
     * @param userIds
     * @param cmd
     */
    @GetMapping("/sendWebSocketMsg")
    public void sendWebSocketMsg(String[] userIds, String cmd) {
        systemApiRestAPI.sendWebSocketMsg(userIds, cmd);
    }


    /**
     * 根据id获取所有参与用户
     * userIds
     *
     * @return
     */
    @GetMapping("/queryAllUserByIds")
    public List<LoginUserDTO> queryAllUserByIds(@RequestParam("userIds") String[] userIds) {
        List<LoginUserDTO> loginUserDTOS = systemApiRestAPI.queryAllUserByIds(userIds);
        return loginUserDTOS;
    }

    /**
     * 查询所有用户 返回ComboModel
     *
     * @return
     */
    @GetMapping("/queryAllUserBackCombo")
    public List<ComboModelDTO> queryAllUserBackCombo() {
        List<ComboModelDTO> comboModels = systemApiRestAPI.queryAllUserBackCombo();
        return comboModels;
    }

    /**
     * 分页查询用户 返回JSONObject
     *
     * @return
     */
    @GetMapping("/queryAllUser")
    public JSONObject queryAllUser(@RequestParam(name = "userIds", required = false) String userIds,
                                   @RequestParam(name = "pageNo", required = false) Integer pageNo,
                                   @RequestParam(name = "pageSize", required = false) int pageSize) {
        JSONObject jsonObject = systemApiRestAPI.queryAllUser(userIds, pageNo, pageSize);
        return jsonObject;
    }


    /**
     * 将会议签到信息推动到预览
     * userIds
     *
     * @param userId
     * @return
     */
    @GetMapping("/meetingSignWebsocket")
    public void meetingSignWebsocket(@RequestParam("userId") String userId) {
        systemApiRestAPI.meetingSignWebsocket(userId);
    }

    /**
     * 根据name获取所有参与用户
     * userNames
     *
     * @return
     */
    @GetMapping("/queryUserByNames")
    public List<LoginUserDTO> queryUserByNames(@RequestParam("userNames") String[] userNames) {
        List<LoginUserDTO> loginUserDTOS = systemApiRestAPI.queryUserByNames(userNames);
        return loginUserDTOS;
    }

    /**
     * 获取用户的角色集合
     *
     * @param username
     * @return
     */
    @GetMapping("/getUserRoleSet")
    public Set<String> getUserRoleSet(@RequestParam("username") String username) {
        Set<String> userRoleSet = systemApiRestAPI.getUserRoleSet(username);
        return userRoleSet;
    }

    /**
     * 获取用户的权限集合
     *
     * @param username
     * @return
     */
    @GetMapping("/getUserPermissionSet")
    public Set<String> getUserPermissionSet(@RequestParam("username") String username) {
        Set<String> userPermissionSet = systemApiRestAPI.getUserPermissionSet(username);
        return userPermissionSet;
    }

    //-----

    /**
     * 判断是否有online访问的权限
     *
     * @param onlineAuthDTO
     * @return
     */
    @PostMapping("/hasOnlineAuth")
    public boolean hasOnlineAuth(@RequestBody OnlineAuthDTO onlineAuthDTO) {
        boolean ret = systemApiRestAPI.hasOnlineAuth(onlineAuthDTO);
        return ret;
    }

    /**
     * 查询用户角色信息
     *
     * @param username
     * @return
     */
    @GetMapping("/queryUserRoles")
    public Set<String> queryUserRoles(@RequestParam("username") String username) {
        Set<String> strings = systemApiRestAPI.queryUserRoles(username);
        return strings;
    }


    /**
     * 查询用户权限信息
     *
     * @param username
     * @return
     */
    @GetMapping("/queryUserAuths")
    public Set<String> queryUserAuths(@RequestParam("username") String username) {
        Set<String> userAuths = systemApiRestAPI.queryUserAuths(username);
        return userAuths;
    }

    /**
     * 通过部门id获取部门全部信息
     */
    @GetMapping("/selectAllById")
    public SysDepartModelDTO selectAllById(@RequestParam("id") String id) {
        SysDepartModelDTO sysDepartModel = systemApiRestAPI.selectAllById(id);
        return sysDepartModel;
    }

    /**
     * 根据用户id查询用户所属公司下所有用户ids
     *
     * @param userId
     * @return
     */
    @GetMapping("/queryDeptUsersByUserId")
    public List<String> queryDeptUsersByUserId(@RequestParam("userId") String userId) {
        List<String> deptUsersByUserId = systemApiRestAPI.queryDeptUsersByUserId(userId);
        return deptUsersByUserId;
    }


    /**
     * 查询数据权限
     *
     * @return
     */
    @GetMapping("/queryPermissionDataRule")
    public List<SysPermissionDataRuleModelDTO> queryPermissionDataRule(@RequestParam("component") String component, @RequestParam("requestPath") String requestPath, @RequestParam("username") String username) {
        List<SysPermissionDataRuleModelDTO> sysPermissionDataRuleModels = systemApiRestAPI.queryPermissionDataRule(component, requestPath, username);
        return sysPermissionDataRuleModels;
    }

    /**
     * 查询用户信息
     *
     * @param username
     * @return
     */
    @GetMapping("/getCacheUser")
    public SysUserCacheInfoDTO getCacheUser(@RequestParam("username") String username) {
        SysUserCacheInfoDTO cacheUser = systemApiRestAPI.getCacheUser(username);
        return cacheUser;
    }

    /**
     * 普通字典的翻译
     *
     * @param code
     * @param key
     * @return
     */
    @GetMapping("/translateDict")
    public String translateDict(@RequestParam("code") String code, @RequestParam("key") String key) {
        String translated = systemApiRestAPI.translateDict(code, key);
        return translated;
    }


    /**
     * 36根据多个用户账号(逗号分隔)，查询返回多个用户信息
     *
     * @param usernames
     * @return
     */
    @RequestMapping("/queryUsersByUsernames")
    public List<JSONObject> queryUsersByUsernames(@RequestParam("usernames") String usernames) {
        List<JSONObject> jsonObjects = systemApiRestAPI.queryUsersByUsernames(usernames);
        return jsonObjects;
    }

    /**
     * 37根据多个用户id(逗号分隔)，查询返回多个用户信息
     *
     * @param ids
     * @return
     */
    @RequestMapping("/queryUsersByIds")
    public List<JSONObject> queryUsersByIds(@RequestParam("ids") String ids) {
        List<JSONObject> jsonObjects = systemApiRestAPI.queryUsersByIds(ids);
        return jsonObjects;
    }

    /**
     * 38根据多个部门编码(逗号分隔)，查询返回多个部门信息
     *
     * @param orgCodes
     * @return
     */
    @GetMapping("/queryDepartsByOrgcodes")
    public List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes) {
        List<JSONObject> jsonObjects = systemApiRestAPI.queryDepartsByOrgcodes(orgCodes);
        return jsonObjects;
    }

    /**
     * 39根据多个部门ID(逗号分隔)，查询返回多个部门信息
     *
     * @param ids
     * @return
     */
    @GetMapping("/queryDepartsByIds")
    public List<JSONObject> queryDepartsByIds(@RequestParam("ids") String ids) {
        List<JSONObject> jsonObjects = systemApiRestAPI.queryDepartsByIds(ids);
        return jsonObjects;
    }

    /**
     * 40发送邮件消息
     *
     * @param email
     * @param title
     * @param content
     */
    @GetMapping("/sendEmailMsg")
    public void sendEmailMsg(@RequestParam("email") String email, @RequestParam("title") String title, @RequestParam("content") String content) {
        systemApiRestAPI.sendEmailMsg(email, title, content);
    }

    /**
     * 41 获取公司下级部门和公司下所有用户信息
     *
     * @param orgCode
     */
    @GetMapping("/getDeptUserByOrgCode")
    public List<Map> getDeptUserByOrgCode(@RequestParam("orgCode") String orgCode) {
        List<Map> deptUserByOrgCode = systemApiRestAPI.getDeptUserByOrgCode(orgCode);
        return deptUserByOrgCode;
    }

    /**
     * 查询分类字典翻译
     *
     * @param ids 分类字典表id
     * @return
     */
    @GetMapping("/loadCategoryDictItem")
    public List<String> loadCategoryDictItem(@RequestParam("ids") String ids) {
        List<String> strings = systemApiRestAPI.loadCategoryDictItem(ids);
        return strings;
    }

    /**
     * 根据字典code加载字典text
     *
     * @param dictCode 顺序：tableName,text,code
     * @param keys     要查询的key
     * @return
     */
    @GetMapping("/loadDictItem")
    public List<String> loadDictItem(@RequestParam("dictCode") String dictCode, @RequestParam("keys") String keys) {
        List<String> strings = systemApiRestAPI.loadDictItem(dictCode, keys);
        return strings;
    }

    /**
     * 根据字典code查询字典项
     *
     * @param dictCode 顺序：tableName,text,code
     * @param dictCode 要查询的key
     * @return
     */
    @GetMapping("/getDictItems")
    public List<DictModelDTO> getDictItems(@RequestParam("dictCode") String dictCode) {
        List<DictModelDTO> dictItems = systemApiRestAPI.getDictItems(dictCode);
        return dictItems;
    }

    /**
     * 根据多个字典code查询多个字典项
     *
     * @param dictCodeList
     * @return key = dictCode ； value=对应的字典项
     */
    @RequestMapping("/getManyDictItems")
    public Map<String, ?> getManyDictItems(@RequestParam("dictCodeList") List<String> dictCodeList) {
        Map<String, ?> manyDictItems = systemApiRestAPI.getManyDictItems(dictCodeList);
        return manyDictItems;
    }

    /**
     * 【下拉搜索】
     * 大数据量的字典表 走异步加载，即前端输入内容过滤数据
     *
     * @param dictCode 字典code格式：table,text,code
     * @param keyword  过滤关键字
     * @return
     */
    @GetMapping("/loadDictItemByKeyword")
    public List<DictModelDTO> loadDictItemByKeyword(@RequestParam("dictCode") String dictCode, @RequestParam("keyword") String keyword, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.loadDictItemByKeyword(dictCode, keyword, pageSize);
        return dictModelDTOList;
    }

    /**
     * 48 普通字典的翻译，根据多个dictCode和多条数据，多个以逗号分割
     *
     * @param dictCodes
     * @param keys
     * @return
     */
    @GetMapping("/translateManyDict")
    public Map<String, ?> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys) {
        Map<String, ?> stringListMap = systemApiRestAPI.translateManyDict(dictCodes, keys);
        return stringListMap;
    }


    /**
     * 获取表数据字典 【接口签名验证】
     *
     * @param table
     * @param text
     * @param code
     * @return
     */
    @GetMapping("/queryTableDictItemsByCode")
    public List<DictModelDTO> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code) {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.queryTableDictItemsByCode(table, text, code);
        return dictModelDTOList;
    }

    /**
     * 查询表字典 支持过滤数据 【接口签名验证】
     *
     * @param table
     * @param text
     * @param code
     * @param filterSql
     * @return
     */
    @GetMapping("/queryFilterTableDictInfo")
    public List<DictModelDTO> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql) {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.queryFilterTableDictInfo(table, text, code, filterSql);
        return dictModelDTOList;
    }

    /**
     * 【接口签名验证】
     * 查询指定table的 text code 获取字典，包含text和value
     *
     * @param table
     * @param text
     * @param code
     * @param keyArray
     * @return
     */
    @Deprecated
    @GetMapping("/queryTableDictByKeys")
    public List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray) {
        List<String> strings = systemApiRestAPI.queryTableDictByKeys(table, text, code, keyArray);
        return strings;
    }


    /**
     * 字典表的 翻译【接口签名验证】
     *
     * @param table
     * @param text
     * @param code
     * @param key
     * @return
     */
    @GetMapping("/translateDictFromTable")
    public String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key) {
        String translated = systemApiRestAPI.translateDictFromTable(table, text, code, key);
        return translated;
    }


    /**
     * 【接口签名验证】
     * 49 字典表的 翻译，可批量
     *
     * @param table
     * @param text
     * @param code
     * @param keys  多个用逗号分割
     * @return
     */
    @GetMapping("/translateDictFromTableByKeys")
    public List<DictModelDTO> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys) {
        List<DictModelDTO> dictModelDTOList = systemApiRestAPI.translateDictFromTableByKeys(table, text, code, keys);
        return dictModelDTOList;
    }

    /**
     * 发送模板信息
     *
     * @param message
     */
    @PostMapping("/sendTemplateMessage")
    public void sendTemplateMessage(@RequestBody MessageDTO message) {
        systemApiRestAPI.sendTemplateMessage(message);
    }

    /**
     * 获取消息模板内容
     *
     * @param code
     * @return
     */
    @GetMapping("/getTemplateContent")
    public String getTemplateContent(@RequestParam("code") String code) {
        String templateContent = systemApiRestAPI.getTemplateContent(code);
        return templateContent;
    }

    /**
     * 保存数据日志
     *
     * @param dataLogDto
     */
    @PostMapping("/saveDataLog")
    public void saveDataLog(@RequestBody DataLogDTO dataLogDto) {
        systemApiRestAPI.saveDataLog(dataLogDto);
    }

    @PostMapping("/addSysFiles")
    public void addSysFiles(@RequestBody SysFilesModelDTO sysFilesModel) {
        systemApiRestAPI.addSysFiles(sysFilesModel);
    }

    @GetMapping("/getFileUrl")
    public String getFileUrl(@RequestParam(name = "fileId") String fileId) {
        String fileUrl = systemApiRestAPI.getFileUrl(fileId);
        return fileUrl;
    }

    /**
     * 更新头像
     *
     * @param loginUserDTO
     * @return
     */
    @PutMapping("/updateAvatar")
    public void updateAvatar(@RequestBody LoginUserDTO loginUserDTO) {
        systemApiRestAPI.updateAvatar(loginUserDTO);
    }

    /**
     * 向app端 websocket推送聊天刷新消息
     *
     * @param userId
     * @return
     */
    @GetMapping("/sendAppChatSocket")
    public void sendAppChatSocket(@RequestParam(name = "userId") String userId) {
        systemApiRestAPI.sendAppChatSocket(userId);
    }


    /**
     * VUEN-2584【issue】平台sql注入漏洞几个问题
     * 部分特殊函数 可以将查询结果混夹在错误信息中，导致数据库的信息暴露
     *
     * @param e
     * @return
     */
    @ExceptionHandler(java.sql.SQLException.class)
    MatApiResponse<?> handleSQLException(Exception e) {
        String msg = e.getMessage();
        String extractvalue = "extractvalue";
        String updatexml = "updatexml";
        if(msg!=null && (msg.toLowerCase().indexOf(extractvalue)>=0 || msg.toLowerCase().indexOf(updatexml)>=0)){
            return MatApiResponse.fail("校验失败，sql解析异常！");
        }
        return MatApiResponse.fail("校验失败，sql解析异常！" + msg);
    }

}
